package com.mxx.common.data.utils;

import com.mxx.common.data.jpa.*;
import org.springframework.data.jpa.domain.Specification;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

/**
 * @author: mxx
 * @date: 2021/8/12
 * @time: 15:14
 * @Description: 描述信息
 */
public class SpecBuild {

    public static <T> LambdaSpecHelper<T> lambdaHelper(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
        return new LambdaSpecHelper<T>(root, builder, query);
    }

    public static <T> IgnoreNullLambdaSpecHelper<T> ignoreNullLambdaHelper(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
        return new IgnoreNullLambdaSpecHelper<T>(root, builder, query);
    }

    public static <T> SpecHelper specHelper(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
        return new SpecHelper(root, builder, query);
    }

    public static <T> IgnoreNullSpecHelper ignoreNullSpecHelper(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
        return new IgnoreNullSpecHelper(root, builder, query);
    }

    public static <T> Specification<T> lambda(LambdaSpec<T> spec) {
        return spec;
    }

    public static <T> Specification<T> ignoreNullLambda(IgnoreNullLambdaSpec<T> spec) {
        return spec;
    }

    public static <T> Specification<T> spec(Spec<T> spec) {
        return spec;
    }

    public static <T> Specification<T> ignoreNullSpec(IgnoreNullSpec<T> spec) {
        return spec;
    }


}
